

package org.tools;


public class RectangleAreaJudge
{

	private float maxX;
	private float minX;
	private float maxY;
	private float minY;

	public RectangleAreaJudge(String points)
	{
		maxX = 0.0F;
		minX = 0.0F;
		maxY = 0.0F;
		minY = 0.0F;
		create(points);
	}

	public void create(String points)
	{
		String pointsArray[] = points.split(";");
		float x1 = Float.parseFloat(pointsArray[0].split(",")[0]);
		float y1 = Float.parseFloat(pointsArray[0].split(",")[1]);
		float x2 = Float.parseFloat(pointsArray[1].split(",")[0]);
		float y2 = Float.parseFloat(pointsArray[1].split(",")[1]);
        System.out.println(String.valueOf(x1)+"--"+y1+"--"+"---"+y2) ;
		if (x1 > x2)
		{
			maxX = x1;
			minX = x2;
		} else
		{
			maxX = x2;
			minX = x1;
		}
		if (y1 > y2)
		{
			maxY = y1;
			minY = y2;
		} else
		{
			maxY = y2;
			minY = y1;
		}
	}

	public String cutDot(String s)
	{
		int dot = s.indexOf(".");
		if (dot < 0)
			return s;
		else
			return (String.valueOf(s.substring(0, dot)))+""+s.substring(dot + 1, s.length()).toString();
	}

	public boolean isInArea(String x, String y)
	{
		float ix = Float.parseFloat(x);
		float iy = Float.parseFloat(y);
		return ix >= minX && ix <= maxX && iy >= minY && iy <= maxY;
	}

	public boolean isInArea(double x, double y)
	{
		return x >= (double)minX && x <= (double)maxX && y >= (double)minY && y <= (double)maxY;
	}

	public static void main(String args[])
	{
		RectangleAreaJudge area = new RectangleAreaJudge("118.126592,30.130026;119.213014,31.139031");
	//	area = new RectangleAreaJudge("113.18389892578125,23.046248208393926;113.41529846191406,23.18013237070759");
		System.out.println(area.isInArea("113.2525", "23.146477"));
	}
}
